angular.module('${menuCode}')
.controller("${widgetCode}Ctrl",function($scope,AppKit){
	$scope.closeModal = function() {
		AppKit.closeModal();
	};
	
	$scope.loadCostDetailData = function() {
		var url='/aeaiem/services/DailyReiDataProvider/rest/daily-rei-detail-tast/'+$scope.detailId ;
		var promise = AppKit.getJsonApi(url);  
		promise.success(function(rspJson){
			$scope.costDetailData = rspJson;
			
			$scope.submitData = new SubmitData();
			$scope.submitData.WFP_ID = $scope.WFP_ID;
			$scope.submitData.WFA_CODE = $scope.WFA_CODE;
			$scope.submitData.WFIP_ID = $scope.WFIP_ID;
			
			if($scope.WFA_CODE == 'detail'){
				$scope.submitButtonShow = false;
				$scope.payButtonShow = false;
			}else if($scope.WFA_CODE == 'rect7'){
				$scope.submitButtonShow = false;
				$scope.payButtonShow = true;
			}else{
				$scope.submitButtonShow = true;
				$scope.payButtonShow = false;
			}
			
		})
	};
	
	$scope.loadCostDetailData();
	
	$scope.submit = function(agreeSign) {
		var url ='/aeaiem/services/TodoTaskDataProvider/rest/daily-todo-task-submit';
		$scope.submitData.result = agreeSign;
		$scope.submitData.money = $scope.costDetailData.money;
		$scope.submitData.id = $scope.costDetailData.id;
		$scope.submitData.title = $scope.costDetailData.title;
		
		AppKit.postJsonApi(url,$scope.submitData).then(function(rspJson){
			AppKit.successPopup({"title":"审批成功!"});
			$scope.loadToduTaskDate();
			AppKit.closeModal();
			
			AppKit.hideMask();
		}); 
	}
	
	$scope.payment = function() {
		var url ='/aeaiem/services/TodoTaskDataProvider/rest/daily-todo-task-pay';
		$scope.submitData.id = $scope.costDetailData.id;
		
		AppKit.postJsonApi(url,$scope.submitData).then(function(rspJson){
			AppKit.successPopup({"title":"付款成功!"});
			$scope.loadToduTaskDate();
			AppKit.closeModal();
			
			AppKit.hideMask();
		}); 
	}
	
	 function SubmitData(){ 
         this.id = '';
         this.money = '';
         this.desc = '';
         this.title = '';
         this.result = '';
         this.WFP_ID = '';
         this.WFA_CODE = '';
         this.WFIP_ID = '';
      }
	
});